﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Web.Security;
using System.Data.SqlClient;
using StudentHookups.WCF;

namespace StudentHookups
{
    public partial class _Default : System.Web.UI.Page
    {
        WCF.WCFClient client = new WCF.WCFClient();

        protected void Page_Load(object sender, EventArgs e)
        {
            string connectionString = WebConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;

            SqlConnection con = new SqlConnection(connectionString);
            try
            {
                con.Open();
                Label1.Text = con.ServerVersion;
                Label1.Text += con.State.ToString();
            }
            catch
            {
                Label1.Text = "Shit aint working";
            }
            finally
            {
                con.Close();
                Label1.Text += con.State.ToString();
               
             
            }
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {   
           
            
        }

        protected void Upload_Click(object sender, EventArgs e)
        {
            if (ImageUpload.HasFile)
            {

                string filename = Path.GetFileName(ImageUpload.FileName);
                string[] splitFilename = filename.Split('.');
                string filepath = "/imgs/" + Membership.GetUser().UserName + "." + splitFilename[1];

                if(File.Exists(filepath)){
                    File.Delete(filepath);
                }
                ImageUpload.SaveAs(Server.MapPath(filepath));
                
            }
        }

    }
}


